<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>简单的例子</title>
</head>

<body>
    <canvas id="canvas" width="150" height="150"></canvas>

    <script>
        var canvas = document.getElementById('canvas');
        if (canvas.getContext) {
            var ctx = canvas.getContext('2d');

            ctx.fillStyle = "rgb(200,0,0)";
            ctx.fillRect(10, 10, 55, 50)

            ctx.fillStyle = "rgba(0,0,200,0.5)";
            ctx.fillRect(50, 30, 65, 50)
            //fillRect 第一二参数是位置（左上），第三四参数是大小（长高）
        }
    </script>
</body>

</html>